import { BasicForm } from '@/components/ProForm/interface/index';
import { Login, User } from '@/api/interface';
import { PublicInterface } from '@/interface/public';

export function useChangePwdForm(proTableBox: PublicInterface.ProTableValue) {
  let changePwdForm = reactive<BasicForm>({
    form: {},
    title: '用户',
    visible: false,
    formCols: 1,
    options: [
      {
        label: 'id',
        prop: 'id',
        hide: true,
        type: 'input'
      },
      {
        type: 'input',
        label: 'username',
        hide: false,
        prop: 'username',
        defaultValue: '',
        rules: [{ required: true, message: 'username', trigger: 'blur' }],
        attrs: {
          disabled: true
        }
      },
      {
        type: 'input',
        label: '新密码',
        hide: false,
        defaultValue: '',
        prop: 'newPassword',

        rules: [{ required: true, message: '请输入新密码', trigger: 'blur' }]
      }
    ]
  });

  const savePwdForm = async (form: Login.ReqLoginForm) => {
    await userUpPasswordManager(form);
    changePwdForm.visible = false;
    elMessage();
    proTableBox.value?.getTableList();
  };
  return {
    changePwdForm,
    savePwdForm
  };
}
